package a.j;

import a.d.t;

import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.*;
import javax.swing.text.html.HTMLDocument;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D;
import java.net.MalformedURLException;
import java.net.URL;

public class m
  extends hg.i_
  implements hg.e_, hg.d_, hg.b_
{
  private static final String f = "y.view.HtmlLabelConfiguration.LINK_CONTEXT";
  private static final byte g = 0;
  private static final byte h = 1;
  private static final Dimension i = new Dimension(1, 1);
  private final JEditorPane j;
  private final byte k;
  public static int l;
  
  public m()
  {
    this((byte)0, null);
  }
  
  public m(JEditorPane paramJEditorPane)
  {
    this((byte)1, paramJEditorPane);
  }
  
  private m(byte paramByte, JEditorPane paramJEditorPane)
  {
    this.k = paramByte;
    this.j = paramJEditorPane;
  }
  
  protected JComponent e(hg paramhg)
  {
    boolean bool = ld.E;
    hb localhb = hb.a();
    if ((bool) || (this.k == 1))
    {
      if (!bool) {}
      localObject = this.j == null ? localhb.d : this.j;
      a((JEditorPane)localObject, paramhg);
      return localObject;
    }
    Object localObject = localhb.e;
    a((JLabel)localObject, paramhg);
    return localObject;
  }
  
  void a(JLabel paramJLabel, hg paramhg)
  {
    paramJLabel.setText("");
    paramJLabel.setFont(paramhg.A);
    paramJLabel.setText(paramhg.v);
    paramJLabel.setBackground(paramhg.y);
    paramJLabel.setForeground(paramhg.M);
    Dimension localDimension = paramJLabel.getPreferredSize();
    if (!ld.E)
    {
      if ((paramhg instanceof jg)) {
        a((jg)paramhg, localDimension);
      }
      paramJLabel.setSize(localDimension.width, localDimension.height);
    }
  }
  
  void a(JEditorPane paramJEditorPane, hg paramhg)
  {
    boolean bool2 = ld.E;
    boolean bool1 = paramhg instanceof jg;
    paramJEditorPane.setEditable(false);
    paramJEditorPane.setText("");
    paramJEditorPane.setText(paramhg.v);
    paramJEditorPane.setFont(paramhg.A);
    paramJEditorPane.setBackground(paramhg.y);
    paramJEditorPane.setForeground(paramhg.M);
    paramJEditorPane.setBorder(null);
    paramJEditorPane.setOpaque(false);
    b(paramJEditorPane, i);
    Dimension localDimension = paramJEditorPane.getPreferredSize();
    if (!bool2)
    {
      if (bool1) {
        a((jg)paramhg, localDimension);
      }
      b(paramJEditorPane, localDimension);
      localDimension = paramJEditorPane.getPreferredSize();
      if (bool2) {}
    }
    else
    {
      if (bool1) {
        a((jg)paramhg, localDimension);
      }
      a(paramJEditorPane, localDimension);
    }
  }
  
  private static void a(JEditorPane paramJEditorPane, Dimension paramDimension)
  {
    paramJEditorPane.setBounds(0, 0, paramDimension.width, paramDimension.height);
    paramJEditorPane.getUI().getRootView(paramJEditorPane).setSize(paramDimension.width, paramDimension.height);
  }
  
  private static void b(JEditorPane paramJEditorPane, Dimension paramDimension)
  {
    paramJEditorPane.setSize(paramDimension.width, paramDimension.height);
    paramJEditorPane.getUI().getRootView(paramJEditorPane).setSize(paramDimension.width, paramDimension.height);
  }
  
  private static void a(jg paramjg, Dimension paramDimension)
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    Dimension localDimension = new Dimension(0, 0);
    c(paramjg, localDimension);
    d(paramjg, localDimension);
    if (!bool2) {}
    ld localld;
    switch (paramjg.N)
    {
    case 4: 
      if (!bool1) {}
      break;
    case 2: 
      localld = paramjg.hb();
      if (!bool2)
      {
        if (localld != null) {
          paramDimension.height = a(paramDimension.height, localld.d() - localDimension.height);
        }
      }
      else if (!bool2) {
        if (!bool1) {
          return;
        }
      }
      break;
    case 3: 
      localld = paramjg.hb();
      if (!bool2)
      {
        if (localld != null)
        {
          paramDimension.width = a(paramDimension.width, localld.c() - localDimension.width);
          paramDimension.height = a(paramDimension.height, localld.d() - localDimension.height);
        }
      }
      else if (!bool2) {
        if (!bool1) {
          return;
        }
      }
      break;
    case 1: 
      localld = paramjg.hb();
      if (localld != null) {
        paramDimension.width = a(paramDimension.width, localld.c() - localDimension.width);
      }
      break;
    }
  }
  
  private static void c(jg paramjg, Dimension paramDimension)
  {
    boolean bool = ld.E;
    Insets localInsets1 = paramjg.y();
    if (!bool) {
      if (localInsets1 == null)
      {
        Insets localInsets2 = hg.S;
        paramDimension.width += localInsets2.left + localInsets2.right;
        paramDimension.height += localInsets2.top + localInsets2.bottom;
        if (!bool) {
          if (!ld.D) {
            return;
          }
        }
      }
      else
      {
        paramDimension.width += localInsets1.left + localInsets1.right;
      }
    }
    paramDimension.height += localInsets1.top + localInsets1.bottom;
  }
  
  private static void d(jg paramjg, Dimension paramDimension)
  {
    boolean bool = ld.E;
    Icon localIcon = paramjg.z();
    if (localIcon != null)
    {
      int m = paramjg.v();
      if (!bool) {}
      switch (paramjg.u())
      {
      case 8: 
      case 16: 
        if (!bool)
        {
          paramDimension.width += localIcon.getIconWidth() + m;
          if (!ld.D) {
            return;
          }
        }
      case 2: 
        paramDimension.height += localIcon.getIconHeight() + m;
      }
    }
  }
  
  private static int a(int paramInt, double paramDouble)
  {
    return Math.max(paramInt, (int)Math.floor(paramDouble));
  }
  
  public void a(hg paramhg, ng paramng, HyperlinkListener paramHyperlinkListener)
  {
    boolean bool = ld.E;
    if (!bool) {
      if (this.k == 1)
      {
        if (bool) {
          break label40;
        }
        d(paramhg, paramng, paramHyperlinkListener);
        if (!ld.D) {
          return;
        }
      }
    }
    label40:
    c(paramhg, paramng, paramHyperlinkListener);
  }
  
  private void c(hg paramhg, ng paramng, HyperlinkListener paramHyperlinkListener)
  {
    boolean bool = ld.E;
    JComponent localJComponent = e(paramhg);
    if ((bool) || ((localJComponent instanceof JLabel)))
    {
      Object localObject = localJComponent.getClientProperty("html");
      if ((bool) || ((localObject instanceof View)))
      {
        b_ localb_1 = (b_)localJComponent.getClientProperty("y.view.HtmlLabelConfiguration.LINK_CONTEXT");
        if (!bool) {
          if (localb_1 == null)
          {
            localb_1 = new b_(null);
            localJComponent.putClientProperty("y.view.HtmlLabelConfiguration.LINK_CONTEXT", localb_1);
          }
        }
        View localView = (View)localObject;
        Document localDocument = localView.getDocument();
        if ((bool) || ((localDocument instanceof HTMLDocument)))
        {
          HTMLDocument localHTMLDocument = (HTMLDocument)localDocument;
          b_ localb_2 = a(localView, localHTMLDocument, paramhg, paramng.a(), paramng.b());
          if (!bool) {}
          switch (paramng.c())
          {
          case 500: 
            localb_1.c = localb_2.c;
            localb_1.a = localb_2.a;
            if ((localb_1.a != null) && ((bool) || (paramHyperlinkListener != null))) {
              paramHyperlinkListener.hyperlinkUpdate(new c_(paramng.getSource(), HyperlinkEvent.EventType.ACTIVATED, a(localHTMLDocument.getBase(), localb_1.c), localb_1.c, localb_1.a, paramhg));
            }
            break;
          case 503: 
            if ((ld.D) && ((bool) || (localb_2.a != localb_1.a)))
            {
              if (!bool) {
                if (localb_2.c == null)
                {
                  if (null == localb_1.c) {
                    break;
                  }
                  break label328;
                }
              }
              if ((bool) || (!localb_2.c.equals(localb_1.c)))
              {
                label328:
                if (!bool)
                {
                  if ((localb_1.c != null) && ((bool) || (paramHyperlinkListener != null))) {
                    paramHyperlinkListener.hyperlinkUpdate(new c_(paramng.getSource(), HyperlinkEvent.EventType.EXITED, a(localHTMLDocument.getBase(), localb_1.c), localb_1.c, localb_1.a, paramhg));
                  }
                  localb_1.c = localb_2.c;
                  localb_1.a = localb_2.a;
                }
                if (localb_1.c != null) {
                  if ((bool) || (paramHyperlinkListener != null)) {
                    paramHyperlinkListener.hyperlinkUpdate(new c_(paramng.getSource(), HyperlinkEvent.EventType.ENTERED, a(localHTMLDocument.getBase(), localb_1.c), localb_1.c, localb_1.a, paramhg));
                  }
                }
              }
            }
            break;
          }
        }
      }
    }
  }
  
  private URL a(URL paramURL, String paramString)
  {
    boolean bool = ld.E;
    URL localURL;
    try
    {
      localURL = new URL(paramURL, paramString);
      if (((bool) || (paramString != null)) && ((bool) || (("file".equals(localURL.getProtocol())) && ((bool) || (paramString.startsWith("#"))))))
      {
        String str1 = paramURL.getFile();
        String str2 = localURL.getFile();
        if (((bool) || (str1 != null)) && ((bool) || (str2 != null)) && (!str2.startsWith(str1))) {
          localURL = new URL(paramURL, str1 + paramString);
        }
      }
    }
    catch (MalformedURLException localMalformedURLException)
    {
      localURL = null;
    }
    return localURL;
  }
  
  private b_ a(View paramView, HTMLDocument paramHTMLDocument, hg paramhg, double paramDouble1, double paramDouble2)
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    b_ localb_ = new b_(null);
    Rectangle2D localRectangle2D = g(paramhg);
    int m = paramHTMLDocument.getEndPosition().getOffset();
    Element localElement = paramHTMLDocument.getCharacterElement(0);
    label213:
    do
    {
      int n;
      for (;;)
      {
        if (localElement == null) {
          break label216;
        }
        AttributeSet localAttributeSet = localElement.getAttributes();
        Object localObject = localAttributeSet.getAttribute(HTML.Tag.A);
        if (!bool2) {
          if ((localObject instanceof AttributeSet)) {
            try
            {
              Shape localShape = paramView.modelToView(localElement.getStartOffset(), Position.Bias.Forward, localElement.getEndOffset(), Position.Bias.Backward, localRectangle2D);
              if (!bool2)
              {
                if (localShape.contains(paramDouble1, paramDouble2))
                {
                  localb_.c = ((String)((AttributeSet)localObject).getAttribute(HTML.Attribute.HREF));
                  if (bool2) {
                    break label218;
                  }
                  localb_.a = localElement;
                }
              }
              else {
                if (!bool1) {
                  break label216;
                }
              }
            }
            catch (BadLocationException localBadLocationException) {}
          }
        }
        n = localElement.getEndOffset() + 1;
        if (bool2) {
          break label213;
        }
        if (n <= m) {
          break;
        }
        localElement = null;
      }
      localElement = paramHTMLDocument.getCharacterElement(n);
    } while (!bool1);
    label216:
    label218:
    return localb_;
  }
  
  private Rectangle2D g(hg paramhg)
  {
    double[] arrayOfDouble = d(paramhg, hb.a().n);
    t localt = paramhg.c();
    double d1 = localt.d() + arrayOfDouble[0];
    double d2 = localt.e() + arrayOfDouble[1];
    a(paramhg, arrayOfDouble);
    return new Rectangle2D.Double(d1, d2, arrayOfDouble[0], arrayOfDouble[1]);
  }
  
  private void d(hg paramhg, ng paramng, HyperlinkListener paramHyperlinkListener)
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    hb localhb = hb.a();
    JComponent localJComponent = e(paramhg);
    if ((localJComponent instanceof JEditorPane))
    {
      double[] arrayOfDouble = d(paramhg, localhb.n);
      t localt = paramhg.c();
      int m = (int)Math.rint(paramng.a() - localt.d() - arrayOfDouble[0]);
      int n = (int)Math.rint(paramng.b() - localt.e() - arrayOfDouble[1]);
      if (501 == paramng.c()) {
        a(a(localJComponent, m, n, paramng, 503), localJComponent);
      }
      HyperlinkListener local0;
      if (paramHyperlinkListener == null)
      {
        local0 = null;
        if (!bool1) {}
      }
      else
      {
        local0 = new HyperlinkListener()
        {
          private final HyperlinkListener val$callback;
          private final ng val$event;
          private final hg val$label;
          
          public void hyperlinkUpdate(HyperlinkEvent paramAnonymousHyperlinkEvent)
          {
            this.val$callback.hyperlinkUpdate(new m.c_(this.val$event.getSource(), paramAnonymousHyperlinkEvent.getEventType(), paramAnonymousHyperlinkEvent.getURL(), paramAnonymousHyperlinkEvent.getDescription(), paramAnonymousHyperlinkEvent.getSourceElement(), this.val$label));
          }
        };
      }
      try
      {
        a(local0, (JEditorPane)localJComponent);
        if (!bool2) {
          if (503 != paramng.c())
          {
            if (!bool2) {
              if (506 != paramng.c()) {
                break label211;
              }
            }
          }
          else
          {
            a(a(localJComponent, m, n, paramng), localJComponent);
            if (bool2) {
              return;
            }
          }
        }
        if (bool1) {
          label211:
          a(a(localJComponent, m, n, paramng), localJComponent);
        }
      }
      finally
      {
        c(local0, (JEditorPane)localJComponent);
      }
    }
  }
  
  private void a(HyperlinkListener paramHyperlinkListener, JEditorPane paramJEditorPane)
  {
    if (paramHyperlinkListener != null) {
      paramJEditorPane.addHyperlinkListener(paramHyperlinkListener);
    }
  }
  
  private void c(HyperlinkListener paramHyperlinkListener, JEditorPane paramJEditorPane)
  {
    if (paramHyperlinkListener != null) {
      paramJEditorPane.removeHyperlinkListener(paramHyperlinkListener);
    }
  }
  
  private MouseEvent a(JComponent paramJComponent, int paramInt1, int paramInt2, ng paramng)
  {
    return a(paramJComponent, paramInt1, paramInt2, paramng, paramng.c());
  }
  
  private MouseEvent a(JComponent paramJComponent, int paramInt1, int paramInt2, ng paramng, int paramInt3)
  {
    return new MouseEvent(paramJComponent, paramInt3, paramng.d(), paramng.e(), paramInt1, paramInt2, paramng.g(), paramng.h(), paramng.f());
  }
  
  private static void a(MouseEvent paramMouseEvent, JComponent paramJComponent)
  {
    paramJComponent.dispatchEvent(paramMouseEvent);
  }
  
  private static final class b_
  {
    Element a;
    String c;
    
    private b_() {}
    
    b_(m.0 param0)
    {
      this();
    }
  }
  
  public static class c_
    extends HyperlinkEvent
  {
    private final hg a;
    public static int b;
    
    public c_(Object paramObject, HyperlinkEvent.EventType paramEventType, URL paramURL, String paramString, Element paramElement, hg paramhg)
    {
      super(paramEventType, paramURL, paramString, paramElement);
      this.a = paramhg;
    }
    
    public hg a()
    {
      return this.a;
    }
    
    public static pg a(Object paramObject)
    {
      return pg.a(paramObject);
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.j.m

 * JD-Core Version:    0.7.0.1

 */